export default {
	// 为当前模块开启命名空间
	namespaced: true,

	state: () => ({
		address: JSON.parse(uni.getStorageSync('address') || '{}'),
		//用户信息对象
		userinfo: JSON.parse(uni.getStorageSync('userinfo') || '{}'),
		token: JSON.parse(uni.getStorageSync('token') || '')
	}),

	mutations: {
		//赋值地址
		saveToaddress(state, address) {
			state.address = address
			this.commit('m_user/saveAddressStorage')
		},
		// 持久化存储address
		saveAddressStorage(state, address) {
			uni.setStorageSync('address', JSON.stringify(state.address))
		},
		//赋值userinfo
		saveUserInfo(state, userinfo) {
			state.userinfo = userinfo
			this.commit('m_user/saveUserInfoStorage')
		},
		// 持久化存储用户信息userinfo
		saveUserInfoStorage(state, userinfo) {
			uni.setStorageSync('userinfo', JSON.stringify(state.userinfo))
		},
		updateToken(state, token) {
			state.token = token
			this.commit('m_user/saveTokenStorage')
		},
		saveTokenStorage(state) {
			uni.setStorageSync('token', JSON.stringify(state.token))
		}
	},
	getters: {

	}
}
